package com.yingdong.sceneserver.inner.message;

import java.util.Collection;

import com.yingdong.sceneserver.net.GameUserSession;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;

public class SendBaseMessage extends Message {



	public SendBaseMessage(int opcode) {
		buffer = ByteBufAllocator.DEFAULT.buffer(INIT_SIZE);
		buffer.writeInt(0);
		buffer.writeInt(0);
		buffer.writeInt(opcode);
	}

	public SendBaseMessage(ByteBuf buffer) {
		this.buffer = buffer;
	
	}

	public SendBaseMessage writeInt(int value) {
		buffer.writeInt(value);
		return this;
	}

	public SendBaseMessage writeShort(int value) {
		buffer.writeShort(value);
		return this;
	}

	public SendBaseMessage writeByte(int value) {
		buffer.writeByte(value);
		return this;
	}

	public SendBaseMessage writeDouble(double value) {
		buffer.writeDouble(value);
		return this;
	}

	public SendBaseMessage writeFloat(float value) {
		buffer.writeFloat(value);
		return this;
	}

	public SendBaseMessage writeLong(long value) {
		buffer.writeLong(value);
		return this;
	}

	public SendBaseMessage writeString(String str) {
		writeString(buffer, str);
		return this;
	}

	public SendBaseMessage writeBytes(byte[] bytes) {
		buffer.writeBytes(bytes);
		return this;
	}

	public SendBaseMessage writeBytes(byte[] bytes, int offset, int length) {
		buffer.writeBytes(bytes, offset, length);
		return this;
	}
	public void sendToClient(GameUserSession session) {
		sendToClient(buffer, session.getSessionId());
	}
	public void sendToClient(int sessionId) {
		sendToClient(buffer, sessionId);
	}
	public void sendToClient(Collection<Integer>sessionList){
		
	}

}
